package com.crl.module.connecter.decoder
{	
	/**
	 *  一次回调解析器;
	 * @author crl
	 * 
	 */	
	public class OnceDecoder extends AbstractDecoder
	{
		public static var POINTER:int=0;
		
		//public var cursor:int;
		
		public var callBack:Function;
		
		public function OnceDecoder(type:String)
		{
			this.type=type;
		}
	
		
		override public function decode() : void{
			var data:Object=this.cmdInfo.data;
			if(this.validate(data)==false)return;
			
			data=parse(data);
			
			this.success(data);
			this.manager.removeDecoder(this);
		}
		
		
		override protected function parse(data:Object) : Object{
			return data;
		}
		
		final protected function success(data:Object):void{
			if(this.callBack !=null){
				this.callBack(data);
			}
		}
		
		override protected function validate(data:Object) : Boolean{
			//确定是否为命令的对应解释者;
			return true;
			//return this.cursor ==this.cmdInfo.data["cursor"];
		}
		
	}
}